import {onBeforeUnmount, onMounted,reactive} from 'vue'
export default function (){

    // 实现鼠标打点的相关数据
    let point =reactive({
        x:0,
        y:0
    }) 
    function savePoint(event){
        point.x = event.pageX
        point.y = event.pageY
        console.log('point', point)
    }

    onMounted(()=>{
        window.addEventListener('click',savePoint)
    })

    // 组件卸载之前移除事件
    onBeforeUnmount(()=>{
        window.removeEventListener('click',savePoint)
    })
    // 函数一定要有返回值
    return point

}